<template>
  <div>
    <div>
      <detail-component ref="detailComponent" :parent_id="contractApply.id"></detail-component>

      <el-descriptions  :column="1" border>
        <el-descriptions-item label="计划部审核意见" :span="1">
         {{contractApply.planOpinion}}

        </el-descriptions-item>
        <el-descriptions-item label="财务部审核意见" :span="1">
          <el-input class="planOpinion" size="mini" v-model="contractApply.financeOpinion" type="textarea"></el-input>

        </el-descriptions-item>
      </el-descriptions>


    </div>

    <!--    底部按钮-->
    <div class="bottom">
      <!--        <el-button type="primary" @click="confirm">确认</el-button>-->

      <el-button type="primary" @click="confirm">同意</el-button>
      <el-button type="warning" @click="reject">驳回</el-button>
      <el-button @click="back">返回</el-button>

    </div>

  </div>
</template>

<script>
import detailComponent from "@/views/contractapply/detail-component.vue";
import qs from "qs";
export default {
  data(){
    return{
      "contractApply": {
        "id": 82,
        "planAgree": null,
        "planOpinion": null,
        "planDate": null,
        "financeId": null,
        "finance": null,
        "financeAgree": null,
        "financeOpinion": null,
        "financeDate": null,
        "leaderId": null,
        "leader": null,
        "leadAgree": null,
        "leadOpinion": null,
        "leadDate": null,
        "status": "待审",

      },
    }
  },

  components:{
    detailComponent
  },
  methods:{
    getData() {
      this.$http({
        url: this.$http.adornUrl(`purchase/contractapply/info/${this.contractApply.id}`),
        method: 'get',

      }).then((data) => {
        this.loading = false
        this.contractApply = data.contractApply
      })
    },
    back(){
      this.$router.go(-1)
    },
    reject(){
      //合同申请计划员审核不通过
      this.contractApply.financeAgree="不同意"
      this.contractApply.status="C001-141"
      this.$http({
        url: this.$http.adornUrl(`purchase/contractapply/finance_agree`),
        method: 'post',

        data:this.contractApply


      }).then((data) => {
        this.$message.success("操作成功")
        this.back()
      })
    },
    confirm(){
      //合同申请计划员已审核
      this.contractApply.status="C001-140"
      this.contractApply.financeAgree="同意"
      this.$http({
        url: this.$http.adornUrl(`purchase/contractapply/finance_agree`),
        method: 'post',

        data:this.contractApply

      }).then((data) => {
        this.$message.success("操作成功")
        this.back()
      })
    }

  },
  mounted() {
    this.contractApply.id=this.$route.query.id
    this.$nextTick(()=>{
      this.getData()
    })

  }

}
</script>

<style lang="scss" scoped>
.bottom{
  text-align: right;
  margin-top: 20px;
}
.planOpinion{
  min-width: 300px;
  //max-width: 600px;
}
::v-deep .el-descriptions-item__cell.el-descriptions-item__label.is-bordered-label{

  width: 150px!important;
}
</style>
